package gov.nist.ssd.swqb.core.search;

import com.hp.hpl.jena.rdf.model.AnonId;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;

import static gov.nist.ssd.swqb.util.Static.concat;

class AnonExactSearch extends AbstractAskSearch {

  private String anonId;
  
	public AnonExactSearch(ExactMatchText searchText, Model model, int requestsSize) {
		super(searchText,
		      model,
		      requestsSize,
		      varName("x"),
		      searchPattern(
		        concat(
		          "ASK {",
		          "  {?a ?b <_:%1$s> . }",
		          "   UNION",
		          "  {<_:%1$s> ?c ?d . }",
		          "}"
		         )
		      )
		    );
		
		this.anonId = searchText.toString();
	}

  @Override
  public RDFNode getNode() {
    return getModel().createResource(AnonId.create(anonId));
  }
}
